/*1 排序 2 查找 3 比较 ----RunTime: 380ms*/


#include <stdio.h>
#include <stdlib.h>

int lengthOfLongestSubstring(char* s) {
    int i, j, k, len = 0;
    for(i = 0, k = 0; s[i] != '\0'; i++)
    {
        for(j = k; j < i; j++)
        {
            if(s[i] == s[j])
            {
                if(i - k > len)
					len = i - k;
				k = j+1;
				break;
            }
        }
    }
    len = len >(i-k)?len:(i-k);
    return len;
}

int main(void)
{
	char str[] = "abcabcbb";
	int ret;
	printf("%d\n", lengthOfLongestSubstring(str));
	return 0;
}